<?php

namespace paper\http\response;

use JetBrains\PhpStorm\Pure;

class ClosureResponse extends Response
{
    //  private \Closure $closure;

    #[Pure] public function __construct(\Closure $closure,$httpCode=200)
    {
        parent::__construct($closure, $httpCode, [], []);
        //  $this->closure = $closure;
    }

    protected function contentType(): string
    {
        return "text/html";
    }

    protected function output($data)
    {
        return $data;
    }

    protected function sendData($data)
    {
        if (is_callable($data))
            call_user_func($data);
        else
            die("is not callable");
    }
}